package com.gientech.redisproducer.controller;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * com.gientech.producer.controller
 *
 * @author: Hero
 * @version: 1.0
 * @date: 2023/2/18
 * @ApiNote: 描述
 * TODO
 **/
@RestController
public class RedisPrducer {
    @Resource
    RedisTemplate redisTemplate;

    // redis键 常量
    public static final String KEY = "myconfig";

    @GetMapping("/producer/{val}")
    public String providder(@PathVariable("val") String val){
        // redis值
        System.out.println(" -value ="+val);
        //设置key值并存入redis
        redisTemplate.opsForValue().set(KEY, val);
        return "成功创建key:"+KEY+",value: "+val;
    }
}
